/** {@code Game}类 对一局游戏的抽象 */
public class Game {
    /** 五张公共牌 */
    protected static Card[] publicCard = new Card[5];

    /** 奖池金额 */
    private static int prizePoolAmount = 0;
    /** 当前回合单人押注额 */
    private static int currentRoundBets = 0;

    /** 重置奖池 */
    public static void resetPrizePool() {
        prizePoolAmount = 0;
        currentRoundBets = 0;
    }

    /** 改变奖池金额 */
    public static void changePrizePoolAmount(int delta) {
        prizePoolAmount += delta;
    }

    /** 设定奖池金额 */
    public static void setPrizePoolAmount(int p) {
        prizePoolAmount = p;
    }

    /** 获取奖池金额 */
    public static int getPrizePoolAmount() {
        return prizePoolAmount;
    }

    /** 获取当前回合单人应当押注额 */
    public static int getCurrentRoundBets() {
        return currentRoundBets;
    }

    /** 设定当前回合单人应当押注额 */
    public static void setCurrentRoundBets(int c) {
        currentRoundBets = c;
    }

    /** 改变当前回合单人应当押注额 */
    public static void changeCurrentRoundBets(int delta) {
        currentRoundBets += delta;
    }

    /** 玩家数组 */
    private static Player[] players = new Player[23];
    private static int numberOfPlayers = 2;// 玩家数量
    private static int indexOfPlayers = 0;// 链表指针

    /** 使用数组实现的存储玩家的循环链表 */
    /** 获取当前玩家 */
    public static Player currentPlayer() {
        return players[indexOfPlayers];
    }

    /** 转向下一个玩家 */
    public static void toNextPlayer() {
        indexOfPlayers++;
        indexOfPlayers %= numberOfPlayers;
    }

    /** 转向下一个局内玩家 */
    public static void toNextTruePlayer() {
        do {
            indexOfPlayers++;
            indexOfPlayers %= numberOfPlayers;
        } while (currentPlayer().getIs出局() || currentPlayer().getIs弃牌());
    }

    /** 设定链表指针 */
    public static void setIndexOfPlayers(int i) {
        indexOfPlayers = i;
    }

    /** 初始化玩家链表 根据玩家数量生成玩家对象 */
    public static void initializePlayers() {
        for (int i = 0; i < numberOfPlayers; i++)
            players[i] = new Player();
    }

    /** 设定玩家数量 */
    public static void setNumberOfPlayers(int num) {
        if (1 < num && num < 24) {
            numberOfPlayers = num;
        } else {
            throw new IllegalArgumentException("玩家数量只能属于[2,23]");
        }
    }

    /** 纯方法类不可以构造 */
    private Game() {
        throw new IllegalStateException("Utility class");
    }
}
